import React from 'react';
import useQueryControlWrap from '../../hooks/useQueryControlWrap'
import { CanvasItemProps } from './../../interface';
import style from './style.module.scss';

export interface ScriptSubmitProps extends CanvasItemProps {
  scriptText?: string
}

export default (props: ScriptSubmitProps) => {
  const { scriptText, domComplete, ...canvasProps } = props;

  useQueryControlWrap(canvasProps.id, '', domComplete);

  return (
    <div
      className={style.wrap}
      {...canvasProps}>
      {`<script type='interceptorsController'>${scriptText || ''}</script>`}
    </div>
  )
}